package test.软件详细设计.atm;

public class ATM {
    private BankCard insertedCard;
    private int balance;

    public ATM() {
        this.balance = 10000; // 初始ATM余额为10000元
    }

    public void insertCard(BankCard card) {
        this.insertedCard = card;
    }

    public boolean verifyPin(String pin) {
        return insertedCard.getPin().equals(pin);
    }

    public boolean withdraw(int amount) {
        if (balance >= amount) {
            balance -= amount;
            return true;
        } else {
            return false;
        }
    }
}

   class BankCard {
    private String cardNumber;
    private String pin;

    public BankCard(String cardNumber, String pin) {
        this.cardNumber = cardNumber;
        this.pin = pin;
    }

    public String getCardNumber() {
        return cardNumber;
    }

    public String getPin() {
        return pin;
    }
}
